﻿
using Microsoft.Extensions.Logging;
using Serilog.Debugging;
using Serilog.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp_GrpcClient
{
    class SerialogLoggerLoggerFactory : ILoggerFactory
    {
        private readonly SerilogLoggerProvider _serialogProvider;

        public SerialogLoggerLoggerFactory(Serilog.ILogger logger = null, bool dispose = false)
        {
            _serialogProvider = new SerilogLoggerProvider(logger, dispose);
        }

        public ILogger CreateLogger(string categoryName)
        {
            return _serialogProvider?.CreateLogger(categoryName);
        }

        public void AddProvider(ILoggerProvider provider)
        {
            SelfLog.WriteLine($"忽略添加Logger {provider}");
        }

        public void Dispose()
        {
            _serialogProvider?.Dispose();
        }
    }
}
